<template>
	<view>

		<view class="container">
			
						<uni-list>	
						<view v-for="(item, index) in friendList">
							<text @click="navTo(item.UserId,item.nickname,item.headimg)">
								<uni-list-item   :title="item.nickname" :note="item.UserId+''" showArrow
									:thumb="item.headimg"
									thumb-size="lg" rightText="小图" />
							</text>
						</view>
						</uni-list>
					
		</view>

	</view>
</template>

<script>
	import {getFriendList} from '@/api/user/friend.js'
	import {getToken,delToken,setToken} from '@/utils/userAuth.js'
	import {setStorageSync,getStorageSync} from '@/utils/storage.js'
	export default {
		data() {
			return {
				navData:1,
				friendList:[
					{
						
					}
				]
			}
		},
		created() {
			var that=this
			var user= getStorageSync('user')
			var data = {
				id: user.userId
			}
			getFriendList(data).then(res => {
				if (res.code == 0) {
					console.log("获取好友列表成功");
					console.log(res.data);
				that.friendList=res.data	
				//缓存好友列表
				setStorageSync("friendInfo_"+user.userId,JSON.stringify(res.data))
				console.log("len:"+that.friendList);
				}
			})
		},
		onLoad() {

		},
		methods: {
			navTo(id,nickName,headimg){
				uni.navigateTo({
					url: '../chat/index?id='+id+"&nickName="+nickName+"&friendImg="+headimg,
					complete: (e) => {
						console.log(e);
					}
				});
			}
		}
	}
</script>

<style>

</style>
